home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / bbs_util / bsrc_260.zip / SRC.ZIP / B_PASSWO.C < prev    next >
C/C++ Source or Header  |  1996-02-20  |  6KB  |  159 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*              (C) Copyright 1987-96, Bit Bucket Software Co.              */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                                                                          */
  14. /*                      BinkleyTerm Password Processor                      */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*    For complete  details  of the licensing restrictions, please refer    */
  18. /*    to the License  agreement,  which  is published in its entirety in    */
  19. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.260.    */
  20. /*                                                                          */
  21. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  22. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  23. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  24. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  25. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  26. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  27. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  28. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* You can contact Bit Bucket Software Co. at any one of the following      */
  32. /* addresses:                                                               */
  33. /*                                                                          */
  34. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  35. /* P.O. Box 460398                AlterNet 7:42/1491                        */
  36. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  37. /*                                Internet f491.n343.z1.fidonet.org         */
  38. /*                                                                          */
  39. /* Please feel free to contact us at any time to share your comments about  */
  40. /* our software and/or licensing policies.                                  */
  41. /*                                                                          */
  42. /*                                                                          */
  43. /*  This module is based largely on a similar module in OPUS-CBCS V1.03b.   */
  44. /*  The original work is (C) Copyright 1987, Wynn Wagner III. The original  */
  45. /*  author has graciously allowed us to use his code in this work.          */
  46. /*                                                                          */
  47. /*--------------------------------------------------------------------------*/
  48.  
  49. /* Include this file before any other includes or defines! */
  50.  
  51. #include "includes.h"
  52.  
  53. char *strnpbk (char *, int);
  54.  
  55. /*--------------------------------------------------------------------------*/
  56. /* N PASSWORD                                                               */
  57. /*--------------------------------------------------------------------------*/
  58.  
  59. int 
  60. n_password (char *theirs, char *ours, int *logit)
  61. {
  62.     int got_one;
  63.     char s_ours[9], s_theirs[9];
  64.  
  65.     if ((ours != NULL) && (ours[0]))
  66.     {
  67.         got_one = 2;
  68.  
  69.         if ((theirs != NULL) && (theirs[0]))
  70.         {
  71.             got_one = 1;
  72.             (void) strnpbk (theirs, 8);    /* Get rid of trailing blanks */
  73.             (void) strnpbk (ours, 8);
  74.  
  75.             if (!strnicmp (theirs, ours, 8))
  76.             {
  77.                 /* If this is the first time, we'll log it.
  78.              * Otherwise, forget it.
  79.              */
  80.  
  81.                 if (*logit)
  82.                 {
  83.                     status_line (MSG_TXT (M_PROTECTED_SESSION));
  84.                     *logit = FALSE;
  85.                 }
  86.                 return 0;
  87.             }
  88.         }
  89.  
  90.         (void) strncpy (s_ours, ours, 8);
  91.         (void) strncpy (s_theirs, theirs, 8);
  92.         s_ours[8] = s_theirs[8] = '\0';
  93.  
  94.         status_line (MSG_TXT (M_PWD_ERROR),
  95.             Full_Addr_Str (&remote_addr),
  96.             theirs,
  97.             ours
  98.             );
  99.  
  100.         return got_one;
  101.     }
  102.     return 0;
  103. }
  104.  
  105. /*--------------------------------------------------------------------------*/
  106. /* N GET PASSWORD                                                           */
  107. /* Find the nodelist entry for this system and point remote_password at     */
  108. /* its password if any                                                      */
  109. /*--------------------------------------------------------------------------*/
  110.  
  111. int 
  112. n_getpassword (ADDRP pw_addr)
  113. {
  114.     int i;
  115.  
  116.     remote_password = NULL;                        /* Default to no password   */
  117.     newnodedes.Password[0] = '\0';
  118.  
  119.     i = nodefind (pw_addr, 0);                    /* find the node in the list*/
  120.     if (i <= 0)
  121.     {
  122.         remote_password = NULL;
  123.         return (i);                                /* return failure if can't  */
  124.     }
  125.  
  126.     if (newnodedes.Password[0] != '\0')            /* If anything there,       */
  127.     {
  128.         remote_password = (char *) (&newnodedes.Password[0]);/* Point at it */
  129.         return (1);                                /* Successful attempt       */
  130.     }
  131.     else
  132.     {
  133.         /* No password involved */
  134.         return (0);
  135.     }
  136. }
  137.  
  138. /*
  139.  * Strip all trailing blanks from a record.
  140.  *
  141.  */
  142.  
  143. char *
  144. strnpbk (register char *string, register int n)
  145. {
  146.     string += n;                                /* point past end of string */
  147.     while (n--)                                    /* now keep count */
  148.     {
  149.         if (*--string)                            /* if there's a character   */
  150.         {
  151.             if (*string != ' ')                    /* if not a blank, we exit  */
  152.                 break;
  153.             *string = '\0';                        /* if blank, terminate here */
  154.         }
  155.     }
  156.     return string;
  157. }
  158.  
  159.